﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="BackgroundScreen.cs" company="">
//   
// </copyright>
// <summary>
//   The background screen.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

/*
 * Author: Juan Mompean Esteban
 * Created: 26-11-2011
 */
namespace ITU_vs_Zombies.Menu.Screens
{
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Content;
    using Microsoft.Xna.Framework.Graphics;

    /// <summary>
    /// The background screen.
    /// </summary>
    internal class BackgroundScreen : GameScreen
    {
        #region Constants and Fields

        /// <summary>
        /// The background texture.
        /// </summary>
        private Texture2D backgroundTexture;

        /// <summary>
        /// The content.
        /// </summary>
        private ContentManager content;

        #endregion

        #region Public Methods

        /// <summary>
        /// The activate.
        /// </summary>
        /// <param name="instancePreserved">
        /// The instance preserved.
        /// </param>
        public override void Activate(bool instancePreserved)
        {
            if (!instancePreserved)
            {
                if (this.content == null)
                {
                    this.content = new ContentManager(this.ScreenManager.Game.Services, "Content");
                }

                this.backgroundTexture = this.content.Load<Texture2D>("background");
            }
        }

        /// <summary>
        /// The draw.
        /// </summary>
        /// <param name="gameTime">
        /// The game time.
        /// </param>
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = this.ScreenManager.SpriteBatch;
            Viewport viewport = this.ScreenManager.GraphicsDevice.Viewport;
            var fullscreen = new Rectangle(0, 0, viewport.Width, viewport.Height);

            spriteBatch.Begin();

            spriteBatch.Draw(this.backgroundTexture, fullscreen, Color.White);

            spriteBatch.End();
        }

        /// <summary>
        /// The unload.
        /// </summary>
        public override void Unload()
        {
            this.content.Unload();
            this.backgroundTexture.Dispose();
        }

        /// <summary>
        /// The update.
        /// </summary>
        /// <param name="gameTime">
        /// The game time.
        /// </param>
        /// <param name="otherScreenHasFocus">
        /// The other screen has focus.
        /// </param>
        /// <param name="coveredByOtherScreen">
        /// The covered by other screen.
        /// </param>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, false);
        }

        #endregion
    }
}